{*
*Author: Daniel Huynh
*Date: Oct 21, 2013

*}
{uniqueid assign=id prepend="sub`$parent`"}
<div class="tz-inner">

    <div class="tz-mainmenu-toggle">
        <a href="#" data-toggle="collapse" data-target=".nav-collapse">
            Main menu                </a>
    </div>

    <div class="pull-left nav-collapse collapse tz-main-menu">
        <ul class="nav menu">
            {$startdepth=$startdepth|default:0}
            {foreach name="children" key=key from=$sections item=section}
            {$nextkey=$key+1}
            {$previouskey=$key-1}

            {if $sections[$nextkey]->depth > $section->depth}
            {$type="label"}
            {elseif $sections[$nextkey]->depth <= $section->depth}
            {$type="content"}
            {/if}

            {if $sections[$previouskey]->depth < $section->depth && $smarty.foreach.children.first!=true}
            <ul class="nav-child unstyled small">
                {/if}
                {if $type=="label"}
                <li class="item-{$id} {if $section->id==$current->id}current{/if}{if $section->depth==0} deeper{/if}{if $sections[$nextkey]->depth > $section->depth} parent{/if}">
                <a href="{$section->link}" {if $section->new_window} target="_blank"{/if}>{if $section->depth==0}
                    {$section->name}
                    {else}
                    {$section->name}
                    {/if}
                </a>
                {elseif $type=="content"}                       
                <li class="item-{$section->id} {if $section->id==$current->id} current{/if} {if $section->depth==0}deeper{/if} {if $sections[$nextkey]->depth < $section->depth}parent{/if}"><a class="" href="{$section->link}"{if $section->new_window} target="_blank"{/if}>{$section->name}</a></li>
                {/if}
                {if $sections[$nextkey]->depth < $section->depth}
                {if $smarty.foreach.children.last==true}
                {$nextdepth=$startdepth}
                {else}
                {$nextdepth=$sections[$nextkey]->depth}
                {/if}
                {$looper=$section->depth-$nextdepth}
                {section name="close" loop=$looper}
                </li>
            </ul>
            {/section}
            </li>
            {/if}
            {/foreach}

        </ul>

    </div>


    <div class="clr"></div>

                </div>